package com.luge.heart;

import java.util.Timer;
import java.util.TimerTask;

import android.content.Intent;
import android.os.Message;

import com.luge.base.Base;
import com.luge.base.BaseNetActivity;
import com.luge.model.request.BaseModel;
import com.luge.model.request.Task;
import com.luge.utils.FileManager;

public class LogoActivity extends BaseNetActivity {

	@Override
	public boolean handleMessage(Message msg) {
		if (msg.what == 0) {
			request(Task.LOGIN, 0);
		} else if (msg.what == Task.LOGIN) {
			BaseModel model = (BaseModel) msg.obj;
			if (preResponse(this, model)) {
				Intent mainIntent = new Intent(this, MainActivity.class);
				startActivity(mainIntent);
				finish();
			}
		}
		return false;
	}

	@Override
	protected String getUrl(int taskID) {
		return getString(R.string.getKey);
	}

	@Override
	protected void init() {
		setContentView(R.layout.logo);
		FileManager fileManager = FileManager.getInstance();
		fileManager.creatDir(Base.cache_path);
		fileManager.creatDir(Base.photo_path);
	}

	@Override
	protected void main() {
		Timer timer = new Timer();
		TimerTask task = new TimerTask() {
			@Override
			public void run() {
				mHandler.sendEmptyMessage(0);
			}
		};
		timer.schedule(task, 1500 * 1);
	}

}
